コード例 #1
0
    def test_just_id(self):
        item = {
            'id': 'a',
            'date': '',
            'title': '',
            'section': '',
            'department': '',
            'epigraph': '',
            'pdf_url': '',
            'xml_url': '',
            'htm_url': ''
        }

        with pytest.raises(ValueError):
            boe_db.boe_diary_entry_query(item)
コード例 #2
0
    def get_sql_query(self):
        with self.input().open('r') as f:
            item = json.loads(f.read())
        item.update(self.entry)

        if not boe_db.boe_diary_entry_is_valid(item):
            raise Exception('Entry does not meet requirements')

        return boe_db.boe_diary_entry_query(item)
コード例 #3
0
    def test_dict(self):
        item = {
            'id': 'a',
            'date': 'b',
            'title': 'c',
            'section': 'd',
            'department': 'e',
            'epigraph': 'f',
            'pdf_url': 'g',
            'xml_url': 'h',
            'htm_url': 'i'
        }

        query = "INSERT INTO boe_diary_entry" \
            "(id, date, title, section, department, epigraph, pdf_url, xml_url, htm_url)" \
            "VALUES ('a', 'b', 'c'," \
            "        'd', 'e', 'f'," \
            "        'g', 'h', 'i');"

        assert boe_db.boe_diary_entry_query(item) == query
コード例 #4
0
    def test_just_id_and_section(self):
        item = {
            'id': 'a',
            'date': '',
            'title': '',
            'section': 'd',
            'department': '',
            'epigraph': '',
            'pdf_url': '',
            'xml_url': '',
            'htm_url': ''
        }

        query = "INSERT INTO boe_diary_entry" \
            "(id, date, title, section, department, epigraph, pdf_url, xml_url, htm_url)" \
            "VALUES ('a', '', ''," \
            "        'd', '', ''," \
            "        '', '', '');"

        assert boe_db.boe_diary_entry_query(item) == query
コード例 #5
0
 def test_none(self):
     with pytest.raises(ValueError):
         boe_db.boe_diary_entry_query(None)
コード例 #6
0
    def test_type_error(self):
        item = set()

        with pytest.raises(ValueError):
            boe_db.boe_diary_entry_query(item)