File: test_parser.py

package info (click to toggle)
finalcif 113%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,568 kB
  • sloc: python: 44,669; sh: 79; makefile: 24
file content (29 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download
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
from pathlib import Path
from unittest import TestCase

from finalcif.cif.cod.website_parser import MyCODStructuresParser


class TestMyCODStructuresParser(TestCase):
    def setUp(self) -> None:
        # Imagine we have a web page from the COD with a list of structures in it
        html = Path('tests/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')