File: test_parser.py

package info (click to toggle)
finalcif 156%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 53,696 kB
  • sloc: python: 50,427; cpp: 67; sh: 51; makefile: 22
file content (30 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pathlib import Path
from unittest import TestCase

from finalcif.cif.cod.website_parser import MyCODStructuresParser

data = Path('tests')

class TestMyCODStructuresParser(TestCase):
    def setUp(self) -> None:
        # Imagine we have a web page from the COD with a list of structures in it
        html = (data / 'statics/cod_struct_list.html').read_text()
        # The pasrer gets initilized
        self.parser = MyCODStructuresParser()
        # And we feed the parser with data
        self.parser.feed(html)

    def test_parse_structures_list_number(self):
        self.assertEqual(self.parser.structures[0]['number'], '3000277')
        self.assertEqual(self.parser.structures[1]['number'], '3000282')

    def test_parse_structures_list_date(self):
        self.assertEqual(self.parser.structures[0]['date'], '2020-08-20')
        self.assertEqual(self.parser.structures[1]['date'], '2020-12-11')

    def test_parse_structures_list_time(self):
        self.assertEqual(self.parser.structures[0]['time'], '13:48:46')
        self.assertEqual(self.parser.structures[1]['time'], '09:03:03')

    def test_parse_token(self):
        self.assertEqual(self.parser.token, 'foo')