コード例 #1
0
    def test_get_files_check_empty(self):
        "Tests empty file if link is empty"
        xml_string = '''
       <files>
        <file>
            <link> </link>
            <size>84</size>
        </file>
       </files>
''';
        xml = etree.fromstring(xml_string)
        files = get_files(xml)
        self.failUnlessEqual(BookFile.objects.all().count(), 0)
コード例 #2
0
    def test_get_files_check_size(self):
        "Tests checking size field"
        xml_string = '''
       <files>
        <file>
            <link> http://link  </link>
            <size>wrong</size>
        </file>
        <file>
            <link> http://link1  </link>
            <size>645</size>
        </file>
       </files>
''';
        xml = etree.fromstring(xml_string)
        files = get_files(xml)
        self.failUnlessEqual(BookFile.objects.all()[0].size, 0)
        self.failUnlessEqual(BookFile.objects.all()[1].size, 645)
コード例 #3
0
    def test_get_files_insert_new(self):
        "Tests insert new fiels"
        xml_string = '''
       <files>
        <file>
            <link> http://link  </link>
            <size></size>
            <type></type>
            <time_found></time_found>
            <last_check></last_check>

            <more_info></more_info>
            <img_link></img_link>
        </file>
       </files>
''';
        xml = etree.fromstring(xml_string)
        files = get_files(xml)

        file = BookFile.objects.get(link='http://link')
        self.failUnlessEqual(BookFile.objects.all()[0].id, file.id)
        self.failUnlessEqual(0, file.size)