Ejemplo n.º 1
0
 def test_bad_path_arg(self):
     self._print(f"CdocsTests.test_bad_path_arg")
     if self.off(): return
     cdocs = Cdocs(PATH)
     self._print("test_bad_path_arg: checking for exceptions")
     with self.assertRaises(DocNotFoundException):
         cdocs.get_doc(None)
     with self.assertRaises(BadDocPath):
         cdocs.get_doc("test.xml")
Ejemplo n.º 2
0
 def test_get_doc_from_root_with_multiple_ext(self):
     self._print(f"CdocsTests.test_get_doc_from_root_with_multiple_ext")
     if self.off(): return
     docpath = "/app/home"
     cdocs = Cdocs(PATH2)
     doc = cdocs.get_doc(docpath)
     self.assertIsNotNone(doc, msg=f'{docpath} must not return None')
     home = doc.find("This is home in text!")
     self.assertNotEqual(
         -1,
         home,
         msg=f'{docpath} must include "This is home in text!" in {doc}')
     doc = cdocs.get_doc(docpath + "/teams")
     self.assertIsNotNone(doc, msg=f'{docpath} must not return None')
     home = doc.find("<teams>")
     self.assertNotEqual(-1,
                         home,
                         msg=f'{docpath} must include "<teams>" in {doc}')
Ejemplo n.º 3
0
 def test_get_doc_not_found(self):
     self._print(f"CdocsTests.test_get_doc_not_found")
     if self.off(): return
     docpath = "/app/home/teams/todos/assignee/fish"
     cdocs = Cdocs(PATH)
     txt = cdocs.get_doc(docpath)
     self._print(f"test_get_doc_not_found: the doc found is: {txt}")
     self.assertIsNotNone(txt, msg=f"doc at {docpath} must not be none")
     self._print(
         f"test_get_doc_not_found: doing get_docs. the doc txt is: {txt}")
     point = txt.find("NO")
     self.assertNotEqual(-1,
                         point,
                         msg=f"txt: {txt} must include 'Not found!'")
Ejemplo n.º 4
0
 def test_concat_json(self):
     self._print(f"\n\n>>>>>>>>>>>>>>>> CdocsTests.test_concat_json")
     if self.off(): return
     docpath = "/app/home+home_screen"
     cdocs = Cdocs(JSON)
     self._print(
         f"CdocsTests.test_concat_json: root name: {cdocs.rootname}")
     doc = cdocs.get_doc(docpath)
     self.assertIsNotNone(doc, msg=f'{docpath} must not return None')
     self._print(f"CdocsTests.test_concat_json: doc: {doc}\n\n\n")
     home = doc.find(
         '{"how-to-use": "How to use My Home", "header": "Home Screen", "content": "The home screen is where you land after logging in."}'
     )
     self.assertNotEqual(
         -1,
         home,
         msg=f'{docpath} must include the joined json, not: {doc}')
Ejemplo n.º 5
0
 def test_get_doc_with_plus_path(self):
     self._print(f"CdocsTests.test_get_doc_with_plus_path")
     if self.off(): return
     docpath = "/app/home/teams/todos/assignee+new_assignee+edit_assignee"
     cdocs = Cdocs(PATH)
     doc = cdocs.get_doc(docpath)
     self._print(
         f"test_get_doc_with_plus_path: content of {docpath} is: {doc}")
     na = doc.find("new assignee")
     ea = doc.find("edit assignee")
     a = doc.find("assignee in company")
     self.assertNotEqual(-1,
                         na,
                         msg=f'must include "new assignee" in {doc}')
     self.assertNotEqual(-1,
                         ea,
                         msg=f'must include "edit assignee" in {doc}')
     self.assertNotEqual(-1,
                         a,
                         msg=f'must include "assignee in company" in {doc}')
Ejemplo n.º 6
0
 def test_get_doc(self):
     self._print(f"CdocsTests.test_get_doc")
     if self.off(): return
     #self._debug()
     docpath = "/app/home/teams/todos/assignee"
     cdocs = Cdocs(PATH)
     txt = cdocs.get_doc(docpath)
     self.assertIsNotNone(txt, msg=f"doc at {docpath} must not be none")
     self._print(f"test_get_doc: doing get_docs. the doc txt is: {txt}")
     point = txt.find("assignee in company starstruck!")
     self.assertNotEqual(
         -1,
         point,
         msg=f"txt: {txt} must include 'assignee in company starstruck!'")
     point = txt.find("my app name: you should see: my app's name is fruit")
     self.assertNotEqual(
         -1,
         point,
         msg=
         "must include 'my app name: you should see: my app's name is fruit'"
     )
Ejemplo n.º 7
0
 def test_doc_at_root(self):
     self._print(f"CdocsTests.test_doc_at_root")
     #
     # we have:
     #   /404x.html
     #   /404
     #   /404a.xml
     #
     docpath = "/#404x.html"
     cdocs = Cdocs(PATH)
     #self._debug()
     self._print(f"CdocsTests.test_doc_at_root. cdocs: {cdocs}")
     doc = cdocs.get_doc(docpath)
     self._print(f"CdocsTests.test_doc_at_root: doc: {doc}")
     self.assertIsNotNone(doc, msg=f"docpath: {docpath} must not be None")
     found = doc.find("REALLY") >= 0
     # should not be found because this root doesn't have html as a format
     # simple pather look using its exts resulting in 404x.html.xml and 404x.html.json
     self.assertEqual(found,
                      False,
                      msg=f"doc at {docpath} must not include 'REALLY'")
Ejemplo n.º 8
0
 def test_index_html(self):
     self._print(f"ApiUiTests.test_index")
     cdocs = Cdocs(ROOT)
     doc = cdocs.get_doc("/v1/index.html")
     self._print(f"ApiUiTests.test_index: doc: {doc}")
Ejemplo n.º 9
0
    def test_finding_doc_at_root_using_cdoc(self):
        self._print(f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc")
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: THIS TEST IS NOT YET DETERMINISTIC."
        )
        #
        # we have:
        #   /404x.html
        #   /404
        #   /404a.xml
        #
        # which is the concept?
        # concepts are:
        #    directory names
        #    any file without an extension
        #    any file with an extension in the exts array
        # everything else must be addressed as directory#filename
        # so:
        #    /404 is a concept you get with /404
        #    /404a.xml is a concept (xml is in the exts array) you get with /404a
        #    /404x.html is a file you get using /#404x.html
        #
        #
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: NOT A DETERMINISTIC TEST!"
        )
        cdocs = Cdocs(PATH)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc. cdocs: {cdocs}"
        )
        self._print("")
        docpath1 = "/404x.html"  # should be not found because not in root with accepts html
        docpath2 = "/#404x.html"  # same
        docpath3 = "/404x"  # not found. this is correct, 404x is html
        docpath4 = "/#404x"  # not found. this is correct, 404x is html
        docpath5 = "/404a"  # found because 404a.xml exists
        docpath6 = "/#404a"  # found because 404a.xml exists. concepts can also be addressed as supporting files.
        docpath7 = "/404a.xml"  # not found because its a full file path not cdocs path
        docpath8 = "/#404a.xml"  # found because can find a full filename on hashmark with cdocs in accepts. the accepts needs to have 'cdocs' because the hashmark is cdocs.
        docpath9 = "/404"  # not found. this is right. cdocs docpath may not have an extension, but files must have extensions.
        docpath10 = "/#404"  # not found. this is right, there is no 404.xml or 404.json.

        doc = cdocs.get_doc(docpath1)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath1}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath2)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath2}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath3)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath3}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath4)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath4}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath5)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath5}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath6)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath6}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath7)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath7}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath8)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath8}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath9)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath9}: doc: {doc}"
        )

        doc = cdocs.get_doc(docpath10)
        self._print(
            f"CdocsSchemeTests.test_finding_doc_at_root_using_cdoc: docpath: {docpath10}: doc: {doc}"
        )