Ejemplo n.º 1
0
    def test_list_files_with_no_files(self):
        """Special case: list files when none present"""

        s = MockSerial([b"",
                        # Get file count
                        self.COUNT_FILES_SNIPPET + b"\r\n",
                        self.COUNT_FILES_SNIPPET + b"\r\n0\r\n",
                        # Enumerate file info
                        self.LIST_FILES_SNIPPET + b"\r\n",
                        self.LIST_FILES_SNIPPET + b"\r\n"])
        n = NodeMCU(s)

        assert n.list_files() == {}

        assert s.finished
Ejemplo n.º 2
0
    def test_list_files_with_no_files(self):
        """Special case: list files when none present"""

        s = MockSerial([
            b"",
            # Get file count
            self.COUNT_FILES_SNIPPET + b"\r\n",
            self.COUNT_FILES_SNIPPET + b"\r\n0\r\n",
            # Enumerate file info
            self.LIST_FILES_SNIPPET + b"\r\n",
            self.LIST_FILES_SNIPPET + b"\r\n"
        ])
        n = NodeMCU(s)

        assert n.list_files() == {}

        assert s.finished
Ejemplo n.º 3
0
    def test_list_files(self):
        """Should send a suitable file-listing command."""

        s = MockSerial([b"",
                        # Get file count
                        self.COUNT_FILES_SNIPPET + b"\r\n",
                        self.COUNT_FILES_SNIPPET + b"\r\n2\r\n",
                        # Enumerate file info
                        self.LIST_FILES_SNIPPET + b"\r\n",
                        self.LIST_FILES_SNIPPET + b"\r\n" +
                        b"7\r\nfoo.txt123\r\n"
                        b"5\r\n\t.tab0\r\n"])
        n = NodeMCU(s)

        assert n.list_files() == {
            "foo.txt": 123,
            "\t.tab": 0,
        }

        assert s.finished
Ejemplo n.º 4
0
    def test_list_files(self):
        """Should send a suitable file-listing command."""

        s = MockSerial([
            b"",
            # Get file count
            self.COUNT_FILES_SNIPPET + b"\r\n",
            self.COUNT_FILES_SNIPPET + b"\r\n2\r\n",
            # Enumerate file info
            self.LIST_FILES_SNIPPET + b"\r\n",
            self.LIST_FILES_SNIPPET + b"\r\n" + b"7\r\nfoo.txt123\r\n"
            b"5\r\n\t.tab0\r\n"
        ])
        n = NodeMCU(s)

        assert n.list_files() == {
            "foo.txt": 123,
            "\t.tab": 0,
        }

        assert s.finished