Exemplo n.º 1
0
    def test_should_parse_eip_details_standards_track(self):
        content = "--- \n" \
                  "eip: 1 \n" \
                  "title: EIP Purpose and Guidelines \n" \
                  "status: Active \n" \
                  "type: Standards Track \n" \
                  "author: Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others \n" \
                  "created: 2015-10-27, 2017-02-01 \n" \
                  "--- \n"

        eip, title, status, eip_type, category, authors, created_raw, created = parse_eip_details(
            content)

        self.assertIsNone(category)
        self.assertEqual(eip, "1")
        self.assertEqual(title, "EIP Purpose and Guidelines")
        self.assertEqual(status, EIP.ACTIVE)
        self.assertEqual(eip_type, EIP.STANDARDS_TRACK)
        self.assertEqual(
            authors,
            "Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others"
        )
        self.assertEqual(created_raw, '2015-10-27, 2017-02-01')

        print(
            "eip {}, title {}, status {}, eip_type {}, category {}, authors {}, created {}"
            .format(eip, title, status, eip_type, category, authors, created))
Exemplo n.º 2
0
    def load_eip(self, content_eip_file):
        b64_content = content_eip_file.content

        file_name = content_eip_file.name
        file_download_url = content_eip_file.download_url
        file_sha = content_eip_file.sha
        file_content = base64.b64decode(b64_content).decode('utf-8')

        eip, title, status, eip_type, category, authors, created_raw, created = parse_eip_details(file_content)

        eip_dict = {
            'eip_num':          eip,
            'eip_title':        title,
            'eip_status':       status,
            'eip_type':         eip_type,
            'eip_category':     category,
            'eip_authors':      authors,
            'eip_created_raw':  created_raw,
            'eip_created':      created,

            'file_name':            file_name,
            'file_download_url':    file_download_url,
            'file_content':         file_content,
            'file_sha':             file_sha,
        }

        return EIP(**eip_dict)
Exemplo n.º 3
0
    def test_should_parse_eip_details_with_other_category(self):
        content = "--- \n" \
                  "eip: 1 \n" \
                  "title: EIP Purpose and Guidelines \n" \
                  "status: draft \n" \
                  "type: Something wrong \n" \
                  "author: Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others \n" \
                  "created: 2015-10-27, 2017-02-01 \n" \
                  "--- \n"

        eip, title, status, eip_type, category, authors, created_raw, created = parse_eip_details(
            content)

        self.assertIsNone(category)
        self.assertEqual(eip, "1")
        self.assertEqual(title, "EIP Purpose and Guidelines")
        self.assertEqual(status, EIP.DRAFT)
        self.assertEqual(eip_type, EIP.OTHER)
        self.assertEqual(
            authors,
            "Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others"
        )
        self.assertEqual(created_raw, "2015-10-27, 2017-02-01")
Exemplo n.º 4
0
    def test_should_parse_eip_details(self):
        content = "--- \n" \
                  "eip: 1 \n" \
                  "title: EIP Purpose and Guidelines \n" \
                  "status: Active \n" \
                  "type: Meta \n" \
                  "author: Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others \n" \
                  "created: 2015-10-27\n" \
                  "--- \n"

        eip, title, status, eip_type, category, authors, created_raw, created = parse_eip_details(
            content)

        self.assertIsNone(category)
        self.assertEqual(eip, "1")
        self.assertEqual(title, "EIP Purpose and Guidelines")
        self.assertEqual(status, EIP.ACTIVE)
        self.assertEqual(eip_type, EIP.META)
        self.assertEqual(
            authors,
            "Martin Becze <*****@*****.**>, Hudson Jameson <*****@*****.**>, and others"
        )
        self.assertEqual(created_raw, "2015-10-27")
        self.assertTrue(isinstance(created, date))