<commit_before>require 'spec_helper'

module Librato
  module Metrics

    describe Annotator do
      before(:all) { prep_integration_tests }
      before(:each) { delete_all_annotations }

      describe "#add" do
        it "should create new annotation" do
          subject.add :deployment, "deployed v68"
          annos = subject.fetch(:deployment, :start_time => Time.now.to_i-60)
          annos["events"]["unassigned"].length.should == 1
          annos["events"]["unassigned"][0]["title"].should == 'deployed v68'
        end
      end

      describe "#delete" do
        it "should remove annotation streams" do
          subject.add :deployment, "deployed v45"
          subject.fetch :deployment # should exist
          subject.delete :deployment
          lambda {
            subject.fetch(:deployment)
          }.should raise_error(Metrics::NotFound)
        end
      end

      describe "#fetch" do
        it "should return annotations" do

        end
      end

      describe "#list" do
        before(:each) do
          subject.add :backups, 'backup 1'
          subject.add :deployment, 'deployed v74'
        end

        context "without arguments" do<commit_msg>Add support for source annotations and start/end times<commit_after>require 'spec_helper'

module Librato
  module Metrics

    describe Annotator do
      before(:all) { prep_integration_tests }
      before(:each) { delete_all_annotations }

      describe "#add" do
        it "should create new annotation" do
          subject.add :deployment, "deployed v68"
          annos = subject.fetch(:deployment, :start_time => Time.now.to_i-60)
          annos["events"]["unassigned"].length.should == 1
          annos["events"]["unassigned"][0]["title"].should == 'deployed v68'
        end
        it "should support sources" do
          subject.add :deployment, 'deployed v69', :source => 'box1'
          annos = subject.fetch(:deployment, :start_time => Time.now.to_i-60)
          annos["events"]["box1"].length.should == 1
          first = annos["events"]["box1"][0]
          first['title'].should == 'deployed v69'
        end
        it "should support start and end times" do
          start_time = Time.now.to_i-120
          end_time = Time.now.to_i-30
          subject.add :deployment, 'deployed v70', :start_time => start_time,
                      :end_time => end_time
          annos = subject.fetch(:deployment, :start_time => Time.now.to_i-180)
          annos["events"]["unassigned"].length.should == 1
          first = annos["events"]["unassigned"][0]
          first['title'].should == 'deployed v70'
          first['start_time'].should == start_time
          first['end_time'].should == end_time
        end
      end

      describe "#delete" do
        it "should remove annotation streams" do
          subject.add :deployment, "deployed v45"
          subject.fetch :deployment # should exist
          subject.delete :deployment
          lambda {
            subject.fetch(:deployment)
          }.should raise_error(Metrics::NotFound)
        end
      end

      describe "#fetch" do
        it "should return annotations" do

        end
      end

      describe "#list" do
        before(:each) do
          subject.add :backups, 'backup 1'
          subject.add :deployment, 'deployed v74'
        end

        context "without arguments" do
{'fraction_non_alphanumeric': 0.11048578199052132, 'fraction_numerical': 0.015106635071090047, 'mean_word_length': 2.200947867298578, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5515104', 'n_tokens_mistral': 987, 'n_tokens_neox': 950, 'n_words': 245}