def test_base_metadata(self):
     note = Note()
     note.title = "test title"
     note.attributes = NoteAttributes()
     featuredict = {}
     features.add_metadata_features(featuredict, note)
     expected_keys = ("META-TITLETOKEN-test", "META-TITLETOKEN-title")
     expected = dict.fromkeys(expected_keys, 1)
     self.assertEqual(featuredict, expected)
def note_featuredict(note, content):
    """Generate a featuredict.

    Args:
        note: Note object.
        content: File-like object containing the note content.

    Returns:
        A dictionary where keys are feature names and values are feature
        values.
    """
    featuredict = {"DEFAULT": 1}
    features.add_metadata_features(featuredict, note)
    if note.attributes.contentClass is None:
        features.add_content_features(featuredict, content)
    return featuredict
 def test_full_metadata(self):
     note = Note()
     note.title = "test title"
     attributes = NoteAttributes()
     note.attributes = attributes
     attributes.sourceURL = "https://testdomain/some/path"
     attributes.latitude = 1
     attributes.source = "testsource"
     attributes.placeName = "testplace"
     attributes.contentClass = "testclass"
     featuredict = {}
     features.add_metadata_features(featuredict, note)
     expected_keys = ("META-TITLETOKEN-test", "META-TITLETOKEN-title",
                      "META-URL-testdomain", "META-HASURL",
                      "META-HASLOCATION", "META-SOURCE-testsource",
                      "META-PLACE-testplace", "META-CONTENTCLASS-testclass")
     expected = dict.fromkeys(expected_keys, 1)
     self.assertEqual(featuredict, expected)